home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / util / cli / WBScreen.lha / src / WBScreen.c < prev   
Encoding:
C/C++ Source or Header  |  1997-08-25  |  3.2 KB  |  112 lines

  1. /*
  2. **  WBScreen.c
  3. **
  4. **  Open or close the Workbench. Can also make another screen the default
  5. **  public screen.
  6. */
  7.  
  8.  
  9. #include <exec/types.h>
  10. #include <intuition/intuition.h>
  11. #include <proto/dos.h>
  12. #include <proto/exec.h>
  13. #include <proto/graphics.h>
  14. #include <proto/intuition.h>
  15. #include <string.h>
  16.  
  17.  
  18.  
  19. UBYTE *Version = { "$VER: WBScreen 2.10 (24.08.97)" };
  20.  
  21.  
  22.  
  23. main( int argc, char *argv[] )
  24. {
  25.   char *ptr, **ttypes;
  26.   ULONG secs;
  27.   
  28.     
  29.   if ( IntuitionBase = ( struct IntuitionBase * )
  30.                                    OpenLibrary( "intuition.library", 37L ))
  31.     {
  32.       if ( ttypes = ArgArrayInit( argc, argv ) )
  33.         {
  34.           ULONG ticks = GfxBase->DisplayFlags & PAL ? 50 : 60;
  35.           
  36.           
  37.           ptr = ArgString( ttypes, "CLOSE", 0 );
  38.           
  39.           if ( ptr )
  40.             CloseWorkBench();
  41.           
  42.           
  43.           ptr = ArgString( ttypes, "OPEN", 0 );
  44.           
  45.           if ( ptr )
  46.             OpenWorkBench();
  47.           
  48.           
  49.           secs = ticks * ( ArgInt( ttypes, "DELAY", 0 ));
  50.           
  51.           if ( secs )
  52.             Delay( secs );      // Wait before trying to find the screen. 
  53.             
  54.           
  55.           ptr = ArgString( ttypes, "DEFAULT", 0 );
  56.           
  57.           if ( ptr )                //  If a pub screen name is specified 
  58.             {                       //  we'll make that one the default.  
  59.               struct Screen *scr;   //  If AUTO is specified, we'll make  
  60.                                     //  the frontmost screen the default. 
  61.               
  62.               if ( stricmp( ptr, "AUTO" ) == NULL )
  63.                 {
  64.                   struct List *psList;
  65.                   struct PubScreenNode *psNode;
  66.                   ULONG lock;
  67.                   
  68.                   lock = LockIBase( NULL );   //  Get a ptr to first scr. 
  69.                   
  70.                     scr = IntuitionBase->FirstScreen;
  71.                     
  72.                   UnlockIBase( lock );  
  73.                     
  74.                   
  75.                   psList = LockPubScreenList();
  76.                   
  77.                   psNode = ( struct PubScreenNode * ) psList->lh_Head;
  78.                   
  79.                   while ( psNode )
  80.                     {
  81.                       if ( scr == psNode->psn_Screen )
  82.                         {
  83.                           ptr = psNode->psn_Node.ln_Name;
  84.                           
  85.                           break;            //  Find the pub screen name  
  86.                         }                   //  of this frontmost screen. 
  87.                       
  88.                       psNode = ( struct PubScreenNode * )
  89.                                                   psNode->psn_Node.ln_Succ;
  90.                     }
  91.                   
  92.                   UnlockPubScreenList();
  93.                 }
  94.               
  95.               
  96.               if ( scr = LockPubScreen( ptr ))
  97.                 {
  98.                   SetDefaultPubScreen( ptr );
  99.                   
  100.                   SetPubScreenModes( POPPUBSCREEN | SHANGHAI );
  101.                   
  102.                   UnlockPubScreen( NULL, scr );
  103.                 }
  104.             }
  105.           
  106.           ArgArrayDone();
  107.         }
  108.       
  109.       CloseLibrary( ( struct Library * ) IntuitionBase );
  110.     }
  111. }
  112.